From 9f70470c55c315477c870bb73494592dd501b630 Mon Sep 17 00:00:00 2001 From: "emellor@ewan" Date: Thu, 22 Sep 2005 16:05:44 +0100 Subject: [PATCH] A number of changes to get save-restore working again: Fix the use of configuration inside domain_configure. The config written by XendDomainInfo.sxpr has moved, and this function needs to change to match. Re-add a call to _add_domain inside domain_restore. Inside XendDomainInfo.restore, perform the appropriate configuration to restore the domain. Validate maxmem_KiB, and cap it at memory_KiB if over that value. Save requires that value to be correct, as the logic for saving only the pages in use is not in place inside Xen. Output the device configuration in sxpr(), as required for save-restore. Check for image being null when trying to call createDeviceModel -- configure is called on restore as well as create, and the ImageHandler instance is not present in the former. Remove dead code create_blkif. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendDomain.py | 9 +++++---- tools/python/xen/xend/XendDomainInfo.py | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 76d4fce4a9..b790f31726 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -299,13 +299,12 @@ class XendDomain: [dominfo.getName(), dominfo.getDomain(), "fail"]) return dominfo - def domain_configure(self, vmconfig): + def domain_configure(self, config): """Configure an existing domain. This is intended for internal use by domain restore and migrate. @param vmconfig: vm configuration """ - config = sxp.child_value(vmconfig, 'config') return XendDomainInfo.restore(self.dbmap.getPath(), config) def domain_restore(self, src, progress=False): @@ -317,7 +316,9 @@ class XendDomain: try: fd = os.open(src, os.O_RDONLY) - return XendCheckpoint.restore(self, fd) + dominfo = XendCheckpoint.restore(self, fd) + self._add_domain(dominfo) + return dominfo except OSError, ex: raise XendError("can't read guest state file %s: %s" % (src, ex[1])) @@ -502,7 +503,7 @@ class XendDomain: """ if domid == PRIV_DOMAIN: - raise XendError("Cannot destroy priviliged domain %i" % domid) + raise XendError("Cannot destroy privileged domain %i" % domid) self.domain_restart_schedule(domid, reason, force=True) dominfo = self.domain_lookup(domid) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index b59adbdf35..5dab516d80 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -172,7 +172,7 @@ class XendDomainInfo: @param uuid: uuid to use """ - log.debug("XendDomainInfo.restore(%s, ..., %s)", dompath, uuid) + log.debug("XendDomainInfo.restore(%s, %s, %s)", dompath, config, uuid) if not uuid: uuid = getUuid() @@ -187,6 +187,9 @@ class XendDomainInfo: vm = cls(uuid, dompath, cls.parseConfig(config), xc.domain_create(ssidref = ssidref)) vm.clear_shutdown() + vm.create_channel() + vm.configure() + vm.exportToDB() return vm restore = classmethod(restore) @@ -382,6 +385,9 @@ class XendDomainInfo: if not self.info['maxmem_KiB']: self.info['maxmem_KiB'] = 1 << 30 + if self.info['maxmem_KiB'] > self.info['memory_KiB']: + self.info['maxmem_KiB'] = self.info['memory_KiB'] + # Validate the given backend names. for s in self.info['backend']: if s not in backendFlags: @@ -607,6 +613,10 @@ class XendDomainInfo: if self.info: sxpr.append(['maxmem', self.info['maxmem_KiB'] / 1024]) + if self.infoIsSet('device'): + for (n, c) in self.info['device']: + sxpr.append(['device', c]) + def stateChar(name): if name in self.info: if self.info[name]: @@ -864,7 +874,8 @@ class XendDomainInfo: """ if not self.rebooting(): self.create_configured_devices() - self.image.createDeviceModel() + if self.image: + self.image.createDeviceModel() def device_create(self, dev_config): """Create a new device. @@ -979,15 +990,6 @@ class XendDomainInfo: """ self.configure_maxmem() self.create_devices() - self.create_blkif() - - def create_blkif(self): - """Create the block device interface (blkif) for the vm. - The vm needs a blkif even if it doesn't have any disks - at creation time, for example when it uses NFS root. - - """ - return def configure_maxmem(self): -- 2.30.2